package com.example.apptest.utils;

import android.Manifest;
import android.app.Activity;
import android.content.pm.PackageManager;

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import com.example.apptest.App;

public class PermissionHelper {

    public static final String[] Permissions = new String[]{
            Manifest.permission.BLUETOOTH,
            Manifest.permission.BLUETOOTH_ADMIN,
            Manifest.permission.BLUETOOTH_SCAN,
            Manifest.permission.BLUETOOTH_CONNECT,
            Manifest.permission.ACCESS_FINE_LOCATION,
            Manifest.permission.ACCESS_COARSE_LOCATION,
            Manifest.permission.READ_CONTACTS
    };

    public static void requestPermission(Activity activity){
        ActivityCompat.requestPermissions(activity, Permissions, 0);
    }

    public static boolean hasPermission(){
        for (String str: Permissions){
            int res = ContextCompat.checkSelfPermission(App.AppContext, str);
            if(res != PackageManager.PERMISSION_GRANTED){
                return false;
            }
        }

        return true;
    }
}
